package com.funny.stock.user.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 密码编码器，一次BCrypt加密
 *
 * @author pengl
 * @date 2020/8/24
 */
public class StockPasswordEncoder implements PasswordEncoder {
    BCryptPasswordEncoder bCryptEncoder;

    public StockPasswordEncoder(){
        bCryptEncoder = new BCryptPasswordEncoder();
    }

    @Override
    public String encode(CharSequence sequence) {

        return bCryptEncoder.encode(sequence);
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return bCryptEncoder.matches(rawPassword,encodedPassword);
    }


}
